package com.yeung.exam;

import java.util.Arrays;
import java.util.Scanner;

public class 小马智行_青蛙朓石头 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int inpu[] = new int[n];
        for (int i = 0; i < n; i++) {
            inpu[i] = sc.nextInt();
        }
        //
        int steps = jump(inpu, 0);
        System.out.println(steps);
    }

    static int jump(int[] data, int start) {
        int dp[] = new int[data.length];
        Arrays.fill(dp, data.length);
        dp[0] = 0;
        for (int i = start; i < data.length; i++) {
            //跳到index+1的石头上
            int way1 = dp[i] + 1;
            //跳到和自己颜色一样的石头上
            int st = sameStone(data, start);

            int way2 = (st != i) ? st - i : data.length;
            int tmp = Math.min(way1, way2);
            if (tmp < dp[i]) {
                dp[i] = tmp;
            }
        }

        return Math.abs(dp[data.length - 1]);

    }

    static int sameStone(int[] data, int start) {
        int index = start;
        for (int i = start + 1; i < data.length; i++) {
            if (data[i] == data[start]) {
                index = i;
                break;
            }
        }
        return index;
    }
}
